<template>
	<view class="" catchtouchmove="return">
		<view class="topNav"></view>
		<view class="contain">
			<view class="title">
				<!--<view class="btn" :class="{contentStatus: connectState}" @tap.stop="goConnect">连接</view>-->
				<view class="btn" :class="{ contentStatus: connectState }" hover-class="hover-dark" @tap.stop="goConnect">{{ lang.work.connect }}</view>
				<!-- <view class="btn" @tap="goInitContent" v-else>连接</view> -->
				<!--<view class="btn" @tap.stop="goStop(0)">断开</view>-->
				<view class="btn" @tap.stop="goStop(0)" hover-class="hover-dark">{{ lang.work.disconnect }}</view>
				<!--<view class="btn" @tap.stop="goFile">下载</view>-->
				<view class="btn" @tap.stop="goFile" hover-class="hover-dark">{{ lang.work.download }}</view>
				<image src="../../static/images/type.png" @tap.stop="goTeam"></image>
				<image src="../../static/images/choice.png" @tap.stop="goShow"></image>
			</view>
			<scroll-view class="navs" scroll-x="true">
				<view :class="navIndex == k ? 'nav-item active' : 'nav-item'" v-for="(v, k) in list" :key="k" @tap.stop="changeNav(k, v.name)">{{ v.name }}</view>
			</scroll-view>
			<view class="all" :style="{ height: heightAll+'px' }">
				<view class="list" :style="{ height: height }">
					<scroll-view class="scroll" scroll-y="true" style="height: 100%;">
						<view class="item" v-for="(item, index) in contentList" :key="index" v-show="groupNum == item.groupNum">
							<view class="item-left">
								<view class="item-title">{{ item.parameterName }}</view>
								<view class="item-content clamp" @tap.stop="userLongtap(item, index)">{{ item.parameterDescription }}</view>
							</view>
							<view class="item-right" @tap.stop="goChange(index, item)">
								<view class="item-text">{{ item.value }}</view>
							</view>
							<view class="item-box" v-if="item.showTips" :class="[index == 0 ? 'item-bottom' : 'item-top']" @tap.stop="userClose(item)">
								<view class="item-box-content">{{ item.parameterDescription }}</view>
							</view>
						</view>
					</scroll-view>
				</view>
				<view class="new-list" v-show="stateShow">
					<view class="icon-con" @tap.stop="onClickDel(1)"><image src="/static/images/qingkong.png" mode=""></image></view>
					<scroll-view style="height: 100%;" scroll-y="true" class="new-box">
						<view class="new-item" v-for="(v, k) in value2" :key="k">{{ v }}</view>
					</scroll-view>
				</view>
				<view class="new-list" v-show="dataShow">
					<view class="icon-con" @tap.stop="onClickDel(0)"><image src="/static/images/qingkong.png" mode=""></image></view>
					<scroll-view style="height: 100%;" scroll-y="true" class="new-box">
						<view class="new-item" v-for="(v, k) in newList" :key="k">
							<view>{{ v.value }}</view>
						</view>
					</scroll-view>
				</view>

				<view class="box" v-if="show" @tap="goHide">
					<view class="box-list" @tap.stop>
						<view class="box-item" @tap="goUpload">
							<image src="../../static/images/shangchuan.png" mode=""></image>
							<!--<view>上传参数</view>-->
							<view>{{ lang.work.uploadpara }}</view>
						</view>
						<view class="box-item" style="margin-top: 30rpx;" @tap="goFile">
							<image src="../../static/images/dakai.png" mode=""></image>
							<!--<view>打开参数文件</view>-->
							<view>{{ lang.work.openparafile }}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="bg" v-if="show1" @tap="goHide1">
				<view class="bg-box" @tap.stop>
					<!--<input type="digit" v-model="value1" placeholder="请输入" />-->
					<input type="digit" focus v-model="value1" :placeholder="lang.work.input" />
					<!--<view class="bg-btn" @tap="goSend">发送</view>-->
					<view class="bg-btn" @tap="goSend">{{ lang.work.send }}</view>
				</view>
			</view>
			<mix-modal ref="mixModal" :title="title" :text="text" @onConfirm="onConfirm"></mix-modal>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import Toast from '../../common/toast.js';
import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue';
import { date } from '@/common/util.js';
export default {
	components: {
		uniNoticeBar
	},
	data() {
		return {
			title: '',
			text: '',
			parameterName: '',
			clickIndex: 0,
			navIndex: 0,
			show: false,
			show1: false,
			nav: [],
			list: [],
			contentList: [],
			contentList1: [],
			contentList2: [],
			newList: [],
			characteristicId: null,
			state: false,
			stateData: true,
			// productState: false,
			linkState: false,
			groupNum: '',
			value1: '',
			value2: [],
			itemIndex: 0,
			minNum: 0,
			maxNum: 0,
			num: 0,
			k: 0,
			m: 0,
			n: 0,
			modifyState: false,
			readState: false,
			oldValue: '',
			oldState: false,
			heightAll: uni.getSystemInfoSync().screenHeight- uni.getSystemInfoSync().statusBarHeight - 170,
			stateChange: false,
			handerSuccess: false,
			connectState: false,
			timer: null,
			canOutLineLinker: false,
			deviceId: null,
			serviceId: null,
			parameterName: '',
			changstarparameterName: '',
			changdata: '',
			coefficientK: '',
			queryPermissionsKey: [],
			rxid:"",
			txid:"",
			isPass:1 //  蓝牙模块是否有权限 0  无  1  有
		};
	},
	computed: {
		...mapState(['lang', 'isPermissions', 'stateShow', 'globalState', 'dataShow', 'canAdd']),
		height() {
			let height = '';
			if (this.dataShow && this.stateShow) {
				height = this.heightAll*0.66 +'px';
			} else if (this.dataShow) {
				height = this.heightAll*0.81 +'px';
			} else if (this.stateShow) {
				height = this.heightAll*0.81+'px';
			} else {
				height = this.heightAll*0.96+'px';
			}
			return height;
		},
		paramList() {
			const paramList = this.$store.state.paramList;
			if (paramList.length != 0) {
				this.init();
				this.readState = false;
				this.$store.commit("setGlobalState", false);
			}
			return this.$store.state.paramList;
		}
	},
	onShow() {
		this.deviceId = this.$store.state.deviceId;
		this.$store.commit('setMessageAdd', true);
		console.log(this.paramList)
	},
	onHide() {
		this.$store.commit('setMessageAdd', false);
	},
	watch: {
		newList: {
			handler(newValue) {
				if (newValue.length > 100) {
					newValue.pop();
				}
			},
			deep: true
		},
		canOutLineLinker(newValue) {
			if (newValue) {
				this.getOutLine();
			}
		}
	},
	methods: {
		//  检查输入值是否符合当前参数系数
		checkValue() {
			let flag = true;
			let str1 = this.value1.split('.')[1];
			let str2 = this.coefficientK.split('.')[1];
			if (str1) {
				str2 ? (str1.length != str2.length ? (flag = false) : '') : (flag = false);
			}
			return flag;
		},
		userClose(item) {
			item.showTips = false;
			this.$forceUpdate();
		},
		userLongtap(item, index) {
			this.contentList.forEach((e, ind) => {
				if (ind == index) {
					e.showTips = true;
				} else {
					e.showTips = false;
				}
			});
			this.$forceUpdate();
			setTimeout(() => {
				item.showTips = false;
				this.$forceUpdate();
			}, 3000);
		},
		//   清空数据
		onConfirm() {
			//if (this.title == "参数修改失败") return;
			if (this.title == this.lang.work.paramodifyfail) return;
			if (this.clickIndex == 0) {
				this.newList = [];
			} else {
				this.value2 = [];
			}
		},
		onClickDel(type) {
			//this.title = "温馨提示";
			this.title = this.lang.work.prompt;
			//this.text = "你确定清空当前内容吗?";
			this.text = this.lang.work.clear;
			this.clickIndex = type;
			this.$refs.mixModal.open();
		},
		changeNav(k, name) {
			this.navIndex = k;
			this.groupNum = name;
		},
		goHide1() {
			this.show1 = false;
			this.value1 = '';
		},
		goSend() {
			// 判断产品是否处于连接状态
			if (!this.connectState) {
				//Toast.showToast("请连接产品");
				Toast.showToast(this.lang.work.connectproduct);
				return;
			}
			if (this.value1 == '') {
				//Toast.showToast("输入值不能为空");
				Toast.showToast(this.lang.work.inputnull);
				return;
			}
			if (this.value1 < this.minNum) {
				//Toast.showToast("输入值超出下限");
				Toast.showToast(this.lang.work.inputovermin);
				return;
			}
			if (this.value1 > this.maxNum) {
				//Toast.showToast("输入值超出上限");
				Toast.showToast(this.lang.work.inputovermax);
				return;
			}
			if (!this.checkValue()) {
				//Toast.showToast("当前输入值与系数不匹配");
				Toast.showToast(this.lang.work.different);
				return;
			}
			this.parameterName = this.changstarparameterName;
			// this.$util.throttle(() => {
				this.show1 = false;
				this.modifyState = true;
				setTimeout(() => {
					this.changeData1(this.value1, 2, this.itemIndex);
				}, 300);
			// });
		},
		goChange(k, item) {
			// console.log(item);
			if (this.isPass == 0) {
				Toast.showToast(this.lang.work.permissions);
				return;
			}
			if (item.groupNum.substring(0, 2) == 'MC') {
				return;
			}
			if (item.write == 1) {
				this.show1 = true;
				this.itemIndex = k;
				this.changstarparameterName = item.parameterName;
				this.coefficientK = item.coefficientK;
				console.log(this.parameterName);
				if (item.symbol == 'Signed') {
					this.minNum = -(Math.pow(2, item.bitLength) - 1) / item.coefficientK + Number(item.deviation);
				} else {
					this.minNum = item.deviation;
				}
				this.maxNum = (Math.pow(2, item.bitLength) - 1) / item.coefficientK + Number(item.deviation);
			} else {
				//Toast.showToast("当前文件不可写入!");
				Toast.showToast(this.lang.work.fileisnotwrite);
			}
		},
		init() {
			uni.showLoading({
				//title: "加载中..."
				title: this.lang.work.loading
			});
			let data1 = {
				ids: this.$store.state.paramList
			};
			let data2 = {
				id: this.$store.state.paramList
			};
			this.$u.get('authc/api/user/find_by_excel_rxid_txid', data2).then(res=>{
				console.log(res)
				if(res.code==0){
					if(res.data.rxid) this.rxid=res.data.rxid;
					if(res.data.txid) this.txid=res.data.txid;
				}
			})
			// // #ifdef MP-WEIXIN
			// let ids='2398bf4bd05e4e3fb9f08fd775f4c52b';
			// let data1 = {ids};
			// //#endif
			// console.log(data1)
			this.$u.get('authc/api/user/find_by_excel_id', data1).then(res => {
				// console.log(res);
				if (res.code == 0) {
					this.list = [];
					this.newList = [];
					this.contentList = [];
					for (let item in res.data) {
						this.list.push({
							name: item,
							content: res.data[item]
						});
					}
					// 获取过来的数据统一加上value值便于页面右侧值的显示
					this.list.forEach((ite, idx) => {
						ite.content.forEach((m, n) => {
							m.value = '';
						});
					});
					this.list.forEach((ite, idx) => {
						// 循环所有数据把MC-STATE的数据单独保存作为循环使用
						if (ite.name.substring(0, 2) == 'MC') {
							ite.content.forEach((item, index) => {
								this.contentList1.push(item);
							});
						}
						// 循环所有数据保存作为循环使用
						ite.content.forEach((item, index) => {
							this.contentList.push(item);
							this.groupNum = this.contentList[0].groupNum;
						});
					});
					uni.hideLoading();
				}
			});
		},
		goShow() {
			if (this.isPass == 0) {
				Toast.showToast(this.lang.work.permissions);
				return;
			}
			this.show = true;
		},
		goHide() {
			this.show = false;
		},
		goTeam() {
			uni.navigateTo({
				url: '/pages/team/team'
			});
		},
		goFile() {
			if (this.isPass == 0) {
				Toast.showToast(this.lang.work.permissions);
				return;
			}
			if (!this.connectState) {
				//Toast.showToast("请连接产品");
				Toast.showToast(this.lang.work.connectproduct);
				return;
			}
			this.show = false;
			uni.navigateTo({
				url: '/pages/file/file?souce=1'
			});
		},
		goUpload() {
			this.show = false;
			if (!this.readState) {
				//Toast.showToast("参数值不能为空，请连接产品");
				Toast.showToast(this.lang.work.paranullconnect);
				return;
			}
			uni.navigateTo({
				url: '/pages/upload/upload'
			});
		},
		goLoad() {
			// 判断产品是否处于连接状态
			if (!this.connectState) {
				//Toast.showToast("请连接产品");
				Toast.showToast(this.lang.work.connectproduct);
				return;
			}

			let item = this.$store.state.changeList;
			if (item == null) {
				//Toast.showToast("参数文件为空，请加载下载参数文件");
				Toast.showToast(this.lang.work.parafilenull);
				return;
			}
			uni.showLoading({
				//title: "准备中..."
				title: this.lang.work.ready
			});
			let list = JSON.parse(item.paramsContent),
				FilterItem;
			list.forEach((ite, idx) => {
				// 循环所有数据把MC-STATE的数据单独保存作为循环使用
				if (ite.groupNum.substring(0, 2) != 'MC') {
					this.contentList2.push(ite);
				}
			});
			this.modifyState = true;
			this.oldState = true;
			setTimeout(() => {
				uni.hideLoading();
				this.changeByteData1(2, 0);
			}, 600);
		},
		goConnect() {
			let self = this;
			if (!self.deviceId) {
				//Toast.showToast("请先连接蓝牙!");
				Toast.showToast(self.lang.work.connectbluetooth);
				return;
			}
			self.canOutLineLinker = false;
			if (self.connectState) {
				self.connectState = false;
				self.k = 0;
				self.m = 0;
				self.num = 0;
				self.modifyState = false;
				self.oldState = false;
				self.getCharacteristics(self.deviceId, self.serviceId);
			} else {
				self.state = false;
				self.num = 0;
				//Toast.showLoading("连接中...");
				Toast.showLoading(self.lang.work.loading);
				uni.createBLEConnection({
					deviceId: self.deviceId,
					success(res) {},
					complete(res) {
						Toast.hideLoading();
					},
					fail(err) {
						console.log(err);
					}
				});
				uni.onBLEConnectionStateChange(function(res) {
					// 该方法回调中可以用于处理连接意外断开等异常情况
					console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`);
					if (res.connected && !self.connectState) {
						setTimeout(() => {
							uni.getBLEDeviceServices({
								// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
								deviceId: self.deviceId,
								success(re) {
									console.log('device services:', JSON.stringify(re));
									re.services.forEach((item, index) => {
										if (item.uuid == '6E400001-B5A3-F393-E0A9-E50E24DCCA9E') {
											self.serviceId = item.uuid;
											self.$store.commit('setServiceId', item.uuid);
											self.getCharacteristics(self.deviceId, item.uuid);
										}
									});
								}
							});
						}, 1000);
					} else {
						if (!self.state) {
							//self.goStop("蓝牙已断开");
							self.goStop(self.lang.work.openbluetooth);
						}
					}
				});
			}
		},
		//  断开 连上状态清除
		initOutLineInner() {
			this.connectState = true;
			this.canOutLineLinker = false;
			this.timer ? clearInterval(this.timer) : '';
		},
		changDataFalseTips(item) {
			//this.value2.unshift(`${item.parameterName}参数修改失败`);
			this.value2.unshift(`${item.parameterName}:` + this.lang.work.paramodifyfail);
			// if (!self.stateShow) {
			//this.title = "参数修改失败";
			this.title = this.lang.work.paramodifyfail;
			//this.text = `${item.parameterName}参数修改失败`;
			this.text = `${item.parameterName}:` + this.lang.work.paramodifyfail;
			this.$refs.mixModal.open();
			this.parameterName = '';
			this.changstarparameterName = '';
		},
		changeDataSuccessTips(item, showValue) {
			//this.value2.unshift(`${item.parameterName}成功修改为:${showValue}`);
			this.value2.unshift(`${item.parameterName}:` + this.lang.work.modifyparasucc + `:${showValue}`);
			this.parameterName = '';
			this.changstarparameterName = '';
		},
		//  数据传换
		linkerFromData(item, index, dataVal, type) {
			item.messageValue = dataVal;

			let rsh = (3 - Math.trunc(item.startingPosition / 8)) * 8 + (item.startingPosition % 8) + 1 - item.bitLength;
			let a = (dataVal >> rsh) & (Math.pow(2, item.bitLength) - 1);
			if (item.symbol == 'Signed') {
				let int16 = new Int16Array([a]);
				a = int16[0];
			}
			// a = a * item.coefficientK + item.deviation;
			a = (a + Number.parseFloat(item.deviation)) * Number.parseFloat(item.coefficientK);
			let showValue = null;
			if (item.statusModelFains) {
				let arry = item.statusModelFains.split('/');
				for (let i = 0, lens = arry.length; i < lens; i++) {
					if (arry[i].substring(0, 1) == a + '') {
						showValue = arry[i];
					}
				}
			}
			if (showValue == null) {
				showValue = this.filterFxed(item, a);
			}
			a = this.filterFxed(item, a);
			item.value = showValue;
			item.realvalue = a;
			if (this.parameterName == item.parameterName) {
				if (type == 1) {
					if (a == this.filterFxed(item, this.value1)) {
						this.changdata = a;
					}
				} else {
					if (this.changdata != a) {
						this.changDataFalseTips(item);
					} else {
						this.changeDataSuccessTips(item, showValue);
					}
				}
			} else {
				if (type == 1) {
					this.changeDataSuccessTips(item, showValue);
				}
			}
		},
		getCharacteristics(deviceId, serviceId) {
			// console.log(deviceId,serviceId)
			// 监听蓝牙特征值变化
			let self = this;
			uni.onBLECharacteristicValueChange(function(e) {
				console.log('onBLECharacteristicValueChange: ' + JSON.stringify(e));
				var v2 = new Uint8Array(e.value);
				console.log('蓝牙反馈数据输出：value(hex) =' + v2);
				if (v2[0] == 0xaa && v2[1] == 0x30 && v2[2] == 0x58 && v2[3] == 0xaa) {
					let byte4 = v2[4];
					let byte5 = v2[5];
					let sendData = new Uint8Array(11);
					sendData[0] = 0x55;
					sendData[1] = 0x30;
					sendData[2] = 0x68;
					sendData[3] = 0xbb;
					sendData[4] = byte4 ^ 0x55;
					sendData[5] = byte5 ^ 0xaa;
					sendData[6] = (sendData[2] + sendData[3] + sendData[4] + sendData[5]) & 0xff;
					let checkSum = 0;
					for (let i = 0; i < 10; i++) {
						checkSum += sendData[i];
					}
					checkSum = checkSum & 0xff;
					sendData[sendData.length - 1] = checkSum;
					console.log(JSON.stringify(sendData));
					if (self.canAdd) {
						self.newList.unshift({
							value: self.toHexStrs(sendData)
						});
					}
					uni.writeBLECharacteristicValue({
						deviceId: self.deviceId,
						serviceId: self.serviceId,
						characteristicId: self.characteristicId,
						value: sendData,
						success: function(res) {
							console.log(res);
						}
					});
				} else if (v2[0] == 0xaa && v2[1] == 0x12 && v2[2] == 0 && v2[3] == 0xbc) {
					console.log('收到仅传输模式回复');
					self.$writeBLECharacteristicValue1();
				} else if (v2[0] == 0xaa && v2[1] == 0x10 && v2[2] == 0 && v2[3] == 0xba) {
					console.log('收到波特率回复');
					self.$writeBLECharacteristicValue();
				} else if (v2[0] == 0xaa && v2[1] == 0x30 && v2[2] == 0x58 && v2[3] == 0xbb && v2[4] == 0xff && v2[5] == 0xff) {
					console.log('收到参数握手回复');
					self.initOutLineInner();
					if (self.isPermissions == 0) {
						self.queryPermissions();
					} else {
						self.sendData();
						//Toast.showToast("产品连接成功");
						Toast.showToast(self.lang.work.productconnectsucc);
						//self.value2.unshift("产品连接成功");
						self.value2.unshift(self.lang.work.productconnectsucc);
					}
				} else if (v2[0] == 0xaa && v2[1] == 0x30 && v2[2] == 0x58 && v2[3] == 0xbb && v2[4] == 0x00 && v2[5] == 0x00) {
					//self.value2.unshift("握手失败!");
					self.value2.unshift(self.lang.work.handshakefail);
					//Toast.showToast("握手失败!");
					Toast.showToast(self.lang.work.handshakefail);
				} else if (v2[0] == 0xaa && v2[1] == 0x23) {
					console.log('收到蓝牙模块权限回复');
					let resvce=v2.slice(2, v2.length - 1);
					self.sendSNToService(resvce);
				} else if (v2[0] == 0xaa && v2[1] == 0x30 && v2[2] == 0x58) {
					console.log('收到蓝牙修改数据成功');
					self.initOutLineInner();
					console.log(self.oldValue[5] == v2[5], self.oldValue[5], v2[5]);
					if (self.oldValue[4] == v2[4] && self.oldValue[5] == v2[5]) {
						console.log(self.toHexStrs(v2));
						console.log(v2[4]);
						console.log(v2[5]);
						let pm = v2[3];
						let dataVal = (v2[4] << 8) + v2[5];
						if (self.canAdd) {
							self.newList.unshift({
								value: self.toHexStrs(v2)
							});
						}
						//  多个  parmas
						let parmas = [];
						self.contentList.forEach((item, index) => {
							if (item.parameterNumber == pm) {
								console.log(item.parameterName + '.........' + item.value);
								item.resvicebyteData = v2;
								self.linkerFromData(item, index, dataVal, 1);
							}
						});
						// console.log(self.oldState);
						if (self.oldState) {
							console.log(self.oldState);
							if (self.n <= self.contentList2.length - 1) {
								if (self.n == self.contentList2.length - 1) {
									self.oldState = false;
									self.$store.commit('setSortList', self.contentList);
									self.m = 0;
									if (self.m <= self.contentList1.length - 1) {
										self.changeData3(1, self.m);
										self.m++;
									} else {
										self.m = 1;
										self.changeData3(1, 0);
									}
								} else {
									self.n++;
									self.changeByteData1(2, self.n);
								}
							}
						} else {
							self.modifyState = false;
							self.changeByteData(self.value1, 1, self.itemIndex);
							self.value1 = '';
						}
					} else {
						self.m = 1;
						self.changeData3(1, 0);
					}
				} else if (v2[0] == 0xaa && v2[1] == 0x30 && v2[2] == 0x59) {
					self.initOutLineInner();
					let pm = v2[3];
					let dataVal = (v2[4] << 8) + v2[5];
					if (self.canAdd) {
						self.newList.unshift({
							value: self.toHexStrs(v2)
						});
					}
					//  多个  parmas
					self.contentList.forEach((item, index) => {
						if (item.parameterNumber == pm) {
							self.linkerFromData(item, index, dataVal);
							item.resvicebyteData = v2;
						}
					});
					// console.log(self.contentList);
					if (!self.modifyState) {
						if (self.k <= self.contentList.length - 1) {
							if (self.k == self.contentList.length - 1) {
								self.readState = true;
								self.$store.commit('setSortList', self.contentList);
								if (self.m <= self.contentList1.length - 1) {
									self.changeData3(1, self.m);
									self.m++;
								} else {
									self.m = 1;
									self.changeData3(1, 0);
								}
							} else {
								self.k++;
								self.sendData();
							}
						}
					} else {
						self.modifyState = false;
					}
				} else {
					if (!self.canOutLineLinker) {
						self.canOutLineLinker = true;
						self.connectState = false;
					}
				}
			});
			uni.getBLEDeviceCharacteristics({
				// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
				deviceId,
				// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
				serviceId,
				success(res) {
					// console.log("device getBLEDeviceCharacteristics:", JSON.stringify(res));
					self.characteristicId = res.characteristics[0].uuid;
					self.$store.commit('setCharacteristicId', res.characteristics[0].uuid);
					for (let i = 0; i < res.characteristics.length; i++) {
						let item = res.characteristics[i];
						if (item.uuid == '6E400003-B5A3-F393-E0A9-E50E24DCCA9E') {
							uni.notifyBLECharacteristicValueChange({
								deviceId,
								serviceId,
								characteristicId: item.uuid,
								state: true,
								success(res) {
									// console.log("notifyBLECharacteristicValueChange:", JSON.stringify(res));
									setTimeout(() => {
										let baud = self.$store.state.baud;
										console.log('当前设置波特率为+++++++++' + baud);
										self.$writeBLECharacteristicValue2(baud);
									}, 300);
								}
							});
						}
					}
				}
			});
		},
		// 对蓝牙设备设置波特率
		$writeBLECharacteristicValue2(val) {
			// 向蓝牙设备发送16进制数据
			// 68 AA 00 00 SS 00 00 00 00
			let intVal = Number.parseFloat(val);
			let self = this;
			let sendData = new Uint8Array(7);
			sendData[0] = 0x55;
			sendData[1] = 0x10;
			sendData[2] = 0x00;
			sendData[3] = intVal >> 16;
			sendData[4] = (intVal >> 8) & 0xff;
			sendData[5] = intVal & 0xff;
			let checkSum = 0;
			for (let i = 0; i < 6; i++) {
				checkSum += sendData[i];
			}
			checkSum = checkSum & 0xff;
			sendData[sendData.length - 1] = checkSum;
			uni.writeBLECharacteristicValue({
				deviceId: self.deviceId,
				serviceId: self.serviceId,
				characteristicId: self.characteristicId,
				value: sendData,
				// value:self.toHexStrs(sendData),
				success: function(res) {
					// console.log(res);
				},
				fail: function(error) {
					console.log(error);
				}
			});
		},
		// 对蓝牙设备设置仅传输模式
		$writeBLECharacteristicValue() {
			let rxid=this.rxid.substring(2);
			let txid=this.txid.substring(2);
			rxid>0x7FF?rxid='04'+rxid:rxid='00'+rxid;
			txid>0x7FF?txid='04'+txid:txid='00'+txid;
			let datas="12"+txid+rxid;
			let sendData = new Uint8Array(1 + datas.length / 2 + 1);
			console.log(datas)
			let length = datas.length;
			sendData[0] = 0x55;
			let checkSum = 0x55;
			for (let i = 0; i < datas.length; i += 2) {
				let a = datas.substring(i, i + 2);
				let num = this.toHex(a);
				sendData[i / 2 + 1] = num;
				checkSum += num;
			}
			checkSum = checkSum & 0xff;
			sendData[sendData.length - 1] = checkSum;
			this.oldValue = sendData;
			console.log(sendData)
			uni.writeBLECharacteristicValue({
				deviceId: this.deviceId,
				serviceId: this.serviceId,
				characteristicId: this.characteristicId,
				value: sendData,
				success: function(res) {
					// console.log(res);
				}
			});
		},
		// 对蓝牙设备进行参数握手
		$writeBLECharacteristicValue1() {
			let datas = '3068AA000012000000';
			let self = this;
			let length = datas.length;
			let sendData = new Uint8Array(1 + datas.length / 2 + 1);
			sendData[0] = 0x55;
			let checkSum = 0x55;
			for (let i = 0; i < datas.length; i += 2) {
				let a = datas.substring(i, i + 2);
				let num = this.toHex(a);
				sendData[i / 2 + 1] = num;
				checkSum += num;
			}
			checkSum = checkSum & 0xff;
			sendData[sendData.length - 1] = checkSum;
			self.oldValue = sendData;
			if (self.canAdd) {
				self.newList.unshift({
					value: self.toHexStrs(sendData)
				});
			}
			uni.writeBLECharacteristicValue({
				deviceId: this.deviceId,
				serviceId: this.serviceId,
				characteristicId: this.characteristicId,
				value: sendData,
				success: function(res) {
					// console.log(res);
				}
			});
		},
		///    收到参数握手回复
		sendData() {
			let self = this;
			this.changeData2(1, this.k);
		},
		//格式化 值
		filterFxed(e, value) {
			let a = value;
			if (e.coefficientK.indexOf('.') != -1) {
				let len = e.coefficientK.split('.')[1].length;
				a = Number(value).toFixed(len);
			}
			return a;
		},
		getBeyLen(bet, betlen) {
			let len = betlen - bet.toString(2).length;
			let bet5 = bet.toString(2);
			for (let i = 0; i < len; i++) {
				bet5 = '0' + bet5;
			}
			return bet5;
		},
		//  收到蓝牙权限回复    生成SN码
		async sendSNToService(byte) {
			let key = this.queryPermissionsKey.slice(2, this.queryPermissionsKey.length - 1);
			console.log('发送权限key.....' + key);
			console.log('收到蓝牙返回key.....' + byte);
			let byteData = new Uint8Array(6);
			byteData[0] = byte[4] ^ (key[3] + key[2]);
			byteData[1] = byte[2] ^ (key[0] - key[1]);
			byteData[2] = byte[1] ^ (key[4] - key[0]);
			byteData[3] = byte[0] ^ (key[2] - key[4]);
			byteData[4] = byte[5] ^ (key[1] + key[5]);
			byteData[5] = byte[3] ^ (key[5] + key[3]);

			let sn = this.toHexStrs(byteData, 'query');
			console.log('发送序列号sn.....' + sn);
			const res = await this.$u.get('authc/api/user/findBySerialNumber', { sn });
			console.log(res);
			if (res.code == 0) {
				this.isPass = res.data.isPass; //  是否有权限
				if (res.data.isPass == 1) {
					//Toast.showToast("产品连接成功");
					Toast.showToast(this.lang.work.productconnectsucc);
					//self.value2.unshift("产品连接成功");
					this.value2.unshift(this.lang.work.productconnectsucc);
					this.sendData();
				} else {
					this.goStop(this.lang.work.permissions);
				}
			}
		},
		// 蓝牙模块权限查询
		queryPermissions() {
			//  生成随机6位字节数
			let byteData = new Uint8Array(9);
			let btyeLen = byteData.length - 3;
			let allDataSum = 0;
			byteData[0] = 0x55; //包头数据
			byteData[1] = 0x23;
			for (let i = 0; i < btyeLen; i++) {
				if (i > 1 && i < btyeLen - 1) {
					// byteData[i] = Number.parseFloat(Math.random() * 10);
					byteData[i] = 0x00;
				}
				allDataSum += byteData[i];
				
			}
			byteData[byteData.length - 1] = allDataSum;
			this.queryPermissionsKey = byteData;
			console.log(byteData);
			// if (this.canAdd) {
			// 	this.newList.unshift({
			// 		value:`发送蓝牙权限查询${this.toHexStrs(byteData)}`
			// 	});
			// }
			uni.writeBLECharacteristicValue({
				deviceId: this.deviceId,
				serviceId: this.serviceId,
				characteristicId: this.characteristicId,
				value: byteData,
				success: res => {
					// console.log(res);
				}
			});
		},
		changeByteData(dataValue, type, k) {
			let self = this;
			var startBit = self.contentList[k].startingPosition;
			var bitLength = self.contentList[k].bitLength;
			var ratio = self.contentList[k].coefficientK;
			var offset = self.contentList[k].deviation;
			var paramNumber = self.contentList[k].parameterNumber;
			var parameterName = self.contentList[k].parameterName;
			var value = self.contentList[k].value;
			var byteData = new Uint8Array(11);
			var $value;
			var baseByteFF = 0xff; //字节拆分
			var byteLength = 2;
			byteData[0] = 0x55; //包头数据
			byteData[1] = 0x30; //仅传输模式
			byteData[3] = paramNumber; //参数号

			//计算偏移位数
			// var rsh=(7 - startBit / 8) * 8 + (startBit % 8) - bitLength + 1;
			var rsh = (Math.trunc(startBit / 8) - 2) * 8 + (8 - (startBit % 8)) - 1;
			// var rsh = startBit-16-1;
			var lsh = 16 - bitLength - rsh;
			let endIndex = rsh + Number(bitLength);
			//数据系数偏移计算
			$value = Number.parseFloat(dataValue);
			console.log($value);
			$value = ($value - offset) / ratio;
			$value = Math.round($value);
			//模式 1读取 2写入
			if (type == 1) {
				byteData[2] = 0x69;
			} else {
				//写入
				byteData[2] = 0x68;
			}
			let parma = [];
			self.contentList.forEach((item, index) => {
				if (item.parameterNumber == paramNumber) {
					parma.push(item);
				}
			});
			console.log(parma);
			if (parma.length > 1) {
				let resvicebyteData = parma[0].resvicebyteData;
				console.log(resvicebyteData);
				let dataVal = self.getBeyLen(resvicebyteData[4], 8) + self.getBeyLen(resvicebyteData[5], 8);
				let str = $value.toString(2),
					zstr = '';
				if (str.length < bitLength) {
					for (let i = 0; i < bitLength - str.length; i++) {
						zstr += '0';
					}
				}
				str = zstr + str;
				dataVal = dataVal.substring(0, rsh) + str + dataVal.substring(endIndex);
				byteData[4] = Number.parseInt(dataVal.substring(0, 8), 2);
				byteData[5] = Number.parseInt(dataVal.substring(8), 2);
			} else {
				//计算全部数据校验和，V0版本从 index=0开始，index=9结束
				for (var i = 0; i < byteLength; i++) {
					var bitOffset = (byteLength - i - 1) * 8;
					// //对比特位进行位移得出单字节数值
					var byteValue = $value >> bitOffset;
					// //清除0-7位之外的比特值
					byteValue = baseByteFF & byteValue;
					byteData[i + 4] = byteValue;
				}
			}

			//计算传输数据校验和，V0版本从 index=2开始，index=5结束
			var dataSum = 0;
			for (var i = 2; i < 6; i++) {
				dataSum += byteData[i];
			}
			byteData[6] = dataSum & baseByteFF;
			var allDataSum = 0;
			for (var i = 0; i < 10; i++) {
				allDataSum += byteData[i];
			}
			byteData[10] = allDataSum & baseByteFF;
			self.oldValue = byteData;
			if (self.canAdd) {
				self.newList.unshift({
					value: self.toHexStrs(byteData)
				});
			}
			uni.writeBLECharacteristicValue({
				deviceId: self.deviceId,
				serviceId: self.serviceId,
				characteristicId: self.characteristicId,
				value: byteData,
				success: res => {
					// console.log(res);
				}
			});
		},
		// 批量修改参数值调用函数
		changeByteData1(type, k) {
			// console.log(k)
			let self = this;
			var startBit = self.contentList2[k].startingPosition;
			var bitLength = self.contentList2[k].bitLength;
			var ratio = self.contentList2[k].coefficientK;
			var offset = self.contentList2[k].deviation;
			var paramNumber = self.contentList2[k].parameterNumber;
			var parameterName = self.contentList2[k].parameterName;
			var value = self.contentList2[k].value;
			var byteData = new Uint8Array(11);
			var $value = Number.parseFloat(value);
			var baseByteFF = 0xff;
			var byteLength = 2;
			byteData[0] = 0x55; //包头数据
			byteData[1] = 0x30; //仅传输模式
			byteData[3] = paramNumber; //参数号

			//计算偏移位数
			// var rsh=(7 - startBit / 8) * 8 + (startBit % 8) - bitLength + 1;
			var rsh = (Math.trunc(startBit / 8) - 2) * 8 + (8 - (startBit % 8)) - 1;
			// var rsh = startBit-16-1;
			var lsh = 16 - bitLength - rsh;
			let endIndex = rsh + Number(bitLength);
			//数据系数偏移计算
			$value = Number.parseFloat(value);
			$value = ($value - offset) / ratio;
			$value = Math.round($value);
			//模式 1读取 2写入
			if (type == 1) {
				byteData[2] = 0x69;
			} else {
				//写入
				byteData[2] = 0x68;
			}
			let parma = [];
			self.contentList2.forEach((item, index) => {
				if (item.parameterNumber == paramNumber) {
					parma.push(item);
				}
			});
			console.log(parma);
			if (parma.length > 1) {
				let resvicebyteData = parma[0].resvicebyteData;
				console.log(resvicebyteData);
				let dataVal = self.getBeyLen(resvicebyteData[4], 8) + self.getBeyLen(resvicebyteData[5], 8);
				let str = $value.toString(2),
					zstr = '';
				if (str.length < bitLength) {
					for (let i = 0; i < bitLength - str.length; i++) {
						zstr += '0';
					}
				}
				str = zstr + str;
				dataVal = dataVal.substring(0, rsh) + str + dataVal.substring(endIndex);
				byteData[4] = Number.parseInt(dataVal.substring(0, 8), 2);
				byteData[5] = Number.parseInt(dataVal.substring(8), 2);
			} else {
				//计算全部数据校验和，V0版本从 index=0开始，index=9结束
				for (var i = 0; i < byteLength; i++) {
					var bitOffset = (byteLength - i - 1) * 8;
					// //对比特位进行位移得出单字节数值
					var byteValue = $value >> bitOffset;
					// //清除0-7位之外的比特值
					byteValue = baseByteFF & byteValue;
					byteData[i + 4] = byteValue;
				}
			}

			//计算传输数据校验和，V0版本从 index=2开始，index=5结束
			var dataSum = 0;
			for (var i = 2; i < 6; i++) {
				dataSum += byteData[i];
			}
			byteData[6] = dataSum & baseByteFF;

			//计算全部数据校验和，V0版本从 index=0开始，index=9结束
			var allDataSum = 0;
			for (var i = 0; i < 10; i++) {
				allDataSum += byteData[i];
			}
			byteData[10] = allDataSum & baseByteFF;
			self.oldValue = byteData;
			if (self.canAdd) {
				self.newList.unshift({
					value: self.toHexStrs(byteData)
				});
			}
			uni.writeBLECharacteristicValue({
				deviceId: self.deviceId,
				serviceId: self.serviceId,
				characteristicId: self.characteristicId,
				value: byteData,
				success: res => {
					if (k == self.contentList2.length - 1 &&self.canAdd) {
						setTimeout(() => {
							//self.value2.unshift("参数下载完成");
							self.value2.unshift(self.lang.work.paraloadsucc);
							//Toast.showToast("参数下载完成");
							Toast.showToast(self.lang.work.paraloadsucc);
						}, 200);
					}
				}
			});
		},
		//  初始化
		changeData2(type = 1, k = 0) {
			// console.log(k);
			let self = this;
			// 判断蓝牙是否处于连接状态
			if (!this.connectState) {
				return;
			}
			var startBit = self.contentList[k].startingPosition;
			var bitLength = self.contentList[k].bitLength;
			var ratio = self.contentList[k].coefficientK;
			var offset = self.contentList[k].deviation;
			var paramNumber = self.contentList[k].parameterNumber;
			var parameterName = self.contentList[k].parameterName;
			var value = self.contentList[k].value;
			var byteData = new Uint8Array(11);
			var $value = Number.parseFloat(value);
			byteData[0] = 0x55; //包头数据
			byteData[1] = 0x30; //仅传输模式
			var baseByteFF = 0xff; //字节拆分
			byteData[3] = paramNumber; //参数号
			//模式 1读取 2写入
			if (type == 1) {
				byteData[2] = 0x69;
			} else {
				//写入
				byteData[2] = 0x68;
			}
			//数据系数偏移计算
			$value = ($value - offset) / ratio;
			$value = Math.round($value);
			//计算偏移位数
			var rsh = (Math.trunc(startBit / 8) - 2) * 8 + (8 - (startBit % 8)) - 1;
			var lsh = 16 - bitLength - rsh;
			$value = $value << lsh;

			//数据字节数
			var byteLength = 2;
			for (var i = 0; i < byteLength; i++) {
				var bitOffset = (byteLength - i - 1) * 8;
				// //对比特位进行位移得出单字节数值
				var byteValue = $value >> bitOffset;
				// //清除0-7位之外的比特值
				byteValue = baseByteFF & byteValue;
				// byteData[i + 4] = byteValue;
				byteData[i + 4] = 0x00;
			}
			//计算传输数据校验和，V0版本从 index=2开始，index=5结束
			var dataSum = 0;
			for (var i = 2; i < 4; i++) {
				dataSum += byteData[i];
			}
			byteData[6] = dataSum & baseByteFF;
			//计算全部数据校验和，V0版本从 index=0开始，index=9结束
			var allDataSum = 0;
			for (var i = 0; i < 10; i++) {
				allDataSum += byteData[i];
			}
			byteData[10] = allDataSum & baseByteFF;
			self.oldValue = byteData;
			if (self.canAdd) {
				self.newList.unshift({
					value: self.toHexStrs(byteData)
				});
			}
			console.log(self.contentList[k].parameterName + '.......' + byteData);
			uni.writeBLECharacteristicValue({
				deviceId: self.deviceId,
				serviceId: self.serviceId,
				characteristicId: self.characteristicId,
				value: byteData,
				success: res => {
					if (k == self.contentList.length - 1) {
						//self.value2.unshift("参数初始化读取完成");
						self.value2.unshift(self.lang.work.readparainitsucc);
						// if (!self.stateShow) {
						//Toast.showToast("参数初始化读取完成");
						Toast.showToast(self.lang.work.readparainitsucc);
						// }
					}
				}
			});
		},
		// 读取MC-STATE数据
		changeData3(type = 1, k = 0) {
			let self = this;
			// 判断蓝牙是否处于连接状态
			if (!this.connectState) {
				return;
			}
			var startBit = self.contentList1[k].startingPosition;
			var bitLength = self.contentList1[k].bitLength;
			var ratio = self.contentList1[k].coefficientK;
			var offset = self.contentList1[k].deviation;
			var paramNumber = self.contentList1[k].parameterNumber;
			var parameterName = self.contentList1[k].parameterName;
			var value = self.contentList1[k].value;
			var byteData = new Uint8Array(11);
			var $value = Number.parseFloat(value);
			var baseByteFF = 0xff; //字节拆分
			var byteLength = 2; //数据字节数
			byteData[0] = 0x55; //包头数据
			byteData[1] = 0x30; //仅传输模式
			byteData[3] = paramNumber; //参数号
			//模式 1读取 2写入
			if (type == 1) {
				byteData[2] = 0x69;
			} else {
				//写入
				byteData[2] = 0x68;
				//数据系数偏移计算
				$value = ($value - offset) / ratio;
				$value = Math.round($value);
				//计算偏移位数
				var rsh = (Math.trunc(startBit / 8) - 2) * 8 + (8 - (startBit % 8)) - 1;
				var lsh = 16 - bitLength - rsh;
				$value = $value << lsh;
				for (var i = 0; i < byteLength; i++) {
					var bitOffset = (byteLength - i - 1) * 8;
					// //对比特位进行位移得出单字节数值
					var byteValue = $value >> bitOffset;
					// //清除0-7位之外的比特值
					byteValue = baseByteFF & byteValue;
					byteData[i + 4] = byteValue;
					// byteData[i + 4] = 0x00;
				}
			}
			//计算传输数据校验和，V0版本从 index=2开始，index=5结束
			var dataSum = 0;
			for (var i = 2; i < 6; i++) {
				dataSum += byteData[i];
			}
			byteData[6] = dataSum & baseByteFF;
			//计算全部数据校验和，V0版本从 index=0开始，index=9结束
			var allDataSum = 0;
			for (var i = 0; i < 10; i++) {
				allDataSum += byteData[i];
			}
			byteData[10] = allDataSum & baseByteFF;
			self.oldValue = byteData;
			if (self.canAdd) {
				self.newList.unshift({
					value: self.toHexStrs(byteData)
				});
			}
			console.log(byteData);
			uni.writeBLECharacteristicValue({
				deviceId: self.deviceId,
				serviceId: self.serviceId,
				characteristicId: self.characteristicId,
				value: byteData,
				success: res => {
					// console.log(res);
				},
				fail: err => {
					// self.value2.push(`${self.contentList1[k].parameterName}参数修改失败`);
				},
				complete(error) {
					// console.log(JSON.stringify(error));
				}
			});
		},
		changeData1(dataValue, type, k) {
			let self = this;
			// 判断产品是否处于连接状态
			if (!this.connectState) {
				return;
			}
			// console.log(dataValue);
			self.changeByteData(dataValue, 2, k);
		},
		getOutLine() {
			this.timer = setInterval(() => {
				this.num += 1;
				if (!this.connectState) {
					this.orangeSendData();
				}
				if (this.num >= 5) {
					//this.goStop("产品已断开!");
					this.goStop(this.lang.work.productopened);
					clearInterval(this.timer);
				}
			}, 1000);
		},
		//   重新发送报文
		orangeSendData() {
			console.log('orangeSendData');
			let _this = this;
			if (_this.canAdd) {
				_this.newList.unshift({
					value: _this.toHexStrs(_this.oldValue)
				});
			}
			uni.writeBLECharacteristicValue({
				deviceId: _this.deviceId,
				serviceId: _this.serviceId,
				characteristicId: _this.characteristicId,
				value: _this.oldValue,
				success: res => {
					console.log(res);
				},
				fail: err => {
					// self.value2.push(`${self.contentList1[k].parameterName}参数修改失败`);
				},
				complete(error) {
					// console.log(JSON.stringify(error));
				}
			});
		},
		//    断开
		goStop(tips) {
			console.log(tips)
				//let text = tips ? tips : "产品断开成功";
				let self = this;
				let text = tips ? tips : self.lang.work.productopensucc;
				uni.closeBLEConnection({
					deviceId: self.deviceId,
					success(res) {
						console.log(res);
						self.k = 0;
						self.m = 0;
						self.modifyState = false;
						self.oldState = false;
						Toast.showToast(text);
						self.value2.unshift(text);
						self.state = true;
						self.connectState = false;
						self.$store.commit('setConnectState',false);
					}
				});
		}
	}
};
</script>

<style lang="less" scoped>
.icon-warper {
	height: 50upx;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.contentStatus {
	background: #cde6c7;
	border-color: #cde6c7 !important;
	//background: #f0f0f0;
	//border-color: #f0f0f0 !important;
}
.item-box {
	position: absolute;
	max-width: 650upx;
	z-index: 999;
	left: 50%;
	transform: translateX(-50%);
}
.item-box-content {
	//background: #cde6c7;
	background: #f0f0f0;
	border-radius: 8upx;
	color: #0070d9;
	width: 650upx;
	padding: 10upx 20upx;
	text-align: left;
	word-wrap: break-word;
	word-break: normal;
}
.item-top {
	top: -90upx;
	.item-box-content::after {
		content: '';
		width: 0;
		height: 0;
		border-left: 8px solid transparent;
		border-right: 8px solid transparent;
		//border-top: 8px solid #cde6c7;
		border-top: 8px solid #f0f0f0;
		position: absolute;
		bottom: -16upx;
		left: 50%;
		transform: translateX(-50%);
	}
}
.item-bottom {
	bottom: -70upx;
	.item-box-content::after {
		content: '';
		width: 0;
		height: 0;
		border-left: 8px solid transparent;
		border-right: 8px solid transparent;
		border-bottom: 8px solid #cde6c7;
		position: absolute;
		top: -16upx;
		left: 50%;
		transform: translateX(-50%);
	}
}

.icon-con {
	width: 60upx;
	height: 60upx;
	z-index: 99;
	display: flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	right: 20upx;
	top: 20upx;
	image {
		width: 32upx;
		height: 32upx;
		z-index: 99;
	}
}
.topNav {
	height: var(--status-bar-height);
	background: #ffffff;
}
.contain {
	width: 750upx;
	background: #f1f1f1;
	display: flex;
	flex-direction: column;
	align-items: center;
	.bg {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		z-index: 99999;
		background: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;

		.bg-box {
			width: 80%;
			padding: 28rpx;
			box-sizing: border-box;
			border-radius: 6px;
			background: #ffffff;
			display: flex;
			flex-direction: column;
			align-items: center;

			input {
				width: 100%;
				height: 80rpx;
				border-bottom: 1px solid #eee;
				font-size: 28rpx;
				color: #333;
				margin-top: 22rpx;
			}

			.bg-btn {
				width: 50%;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				border-radius: 6px;
				background: #1689be;
				font-size: 30rpx;
				color: #ffffff;
				margin: 50rpx 0 22rpx;
			}
		}
	}

	.box {
		width: 100%;
		position: fixed;
		top: 140rpx;
		left: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.4);
		z-index: 9999999;

		.box-list {
			width: 50%;
			padding: 40rpx 28rpx;
			box-sizing: border-box;
			border-radius: 6px;
			background: #ffffff;
			position: absolute;
			top: 60rpx;
			right: 28rpx;

			.box-item {
				width: 100%;
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #777777;

				image {
					width: 38rpx;
					height: 38rpx;
					margin-right: 30rpx;
				}
			}
		}

		.box-list:before {
			content: '';
			width: 0;
			height: 0;
			border-left: 8px solid transparent;
			border-right: 8px solid transparent;
			border-bottom: 16px solid #ffffff;
			position: absolute;
			top: -16px;
			right: 10px;
		}
	}

	.title {
		width: 100%;
		padding: 20rpx 28rpx 0;
		box-sizing: border-box;
		background: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		font-weight: 500;

		.btn {
			width: 150rpx;
			height: 25px;
			line-height: 25px;
			text-align: center;
			border-radius: 4px;
			border: 1px solid #1689be;
			font-size: 28rpx;
			color: #1689be;
		}

		image {
			width: 46rpx;
			height: 46rpx;
		}
	}

	.navs {
		width: 100%;
		height: 50px;
		line-height: 50px;
		white-space: nowrap;
		padding: 0 28rpx;
		background: #fff;
		z-index: 99;
		vertical-align: middle;

		.nav-item {
			display: inline-block;
			height: 50px;
			line-height: 50px;
			margin-right: 36rpx;
			font-size: 30rpx;
			color: #333;

			&.active {
				color: #1689be !important;
				border-bottom: 2px solid #1689be;
			}
		}
	}

	.all {
		width: 100%;
		display: flex;
		flex-direction: column;

		.list {
			width: 96%;
			background: #ffffff;
			border-radius: 6px;
			margin: 5% auto;
			box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);

			.scroll {
				width: 100%;

				.item {
					width: 100%;
					padding: 24rpx;
					line-height: 60rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 34rpx;
					color: #333;
					border-bottom: 1px solid #eee;
					position: relative;
					.item-left {
						display: flex;
						align-items: center;
						width: 80%;

						.item-title {
							width: 130rpx;
							font-size: 34rpx;
							color: #333;
							font-weight: 500;
						}

						.item-content {
							// width:600rpx;
							fill: 1;
							font-size: 30rpx;
							color: #666;
							text-align: left;
							max-width: 430rpx;
						}
					}

					.item-right {
						// width:130rpx;
						font-size: 34rpx;
						color: #333;
						font-weight: 500;
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-self: center;

						.item-text {
							width: 100%;
							text-align: right;
						}
					}
				}

				.item:last-child {
					border-bottom: none;
				}
			}
		}

		.new-list {
			width: 96%;
			flex: 1;
			min-height:150upx;
			height: 10%;
			background: #ffffff;
			border-radius: 6px;
			margin: 0 auto 5%;
			box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
			padding: 24rpx;
			box-sizing: border-box;
			position: relative;
			overflow: hidden;
			.new-box {
				width: 100%;
				display: flex;
				flex-direction: column;

				.new-item {
					width: 100%;
					height: 75rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 34rpx;
					color: #333;
				}
			}
		}
	}
}
</style>
